/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Assembler;

import Common.Instruction;

/**
 *
 * @author Scott
 */
public class SymbolRow
{
    public IntermediateData Data;
    public String Relocation;
    public String Usage;
    public String EquString;
    public String LC;
    
    public SymbolRow(IntermediateData data)
    {
        Data = data;
    }

    public void GetData()
    {
        Usage = "";
        EquString = "n/a";
        LC = null;
        Relocation = Data.Absolute;
        
        if(Data.Type == Instruction.Type.DIRECTIVE)
        {
            if(Data.Directive.ConsumesMemory == false)
            {
                LC = "n/a";
            }
            if(Data.Directive == Instruction.GetDirective("START"))
            {
                LC = null;
                Usage = "PgmName";
            }
            else if(Data.Directive == Instruction.GetDirective("EQU"))
            {
                Usage = "EQU";
                //if(Data.Absolute == true)
                {
                    EquString = Data.EquValue;
                }
            }
            else if(Data.Directive == Instruction.GetDirective("EQUE"))
            {
                Usage = "EQUe";
                EquString = Data.EquValue;
            }
            else if(Data.Directive == Instruction.GetDirective("EXTRN"))
            {
                Usage = "EXTRN";
            }
            else if(Data.Directive.ConsumesMemory == true)
            {
                Usage = "Data";
            }
            else
            {
                Usage = "Label";
            }
        }
        else if(Data.Type == Instruction.Type.OPERATOR)
        {
            Usage = "Label";
        }
    }

    public void PrintRow(String label)
    {
        System.out.printf("%-33s", label);
        if(LC == null)
        {
            System.out.printf("%-5X", Data.LC);
        }
        else
        {
            System.out.printf("%-5s", LC);
        }
        System.out.printf("%-12s", Relocation);
        System.out.printf("%-9s", Usage);
        System.out.printf("%-7s\n", EquString);
    }
}
